package unittest
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	import shooting.ui.MissileContainer;
	import shooting.ui.UnitContainer;
	import shooting.ui.layer.BitmapLayer;
	import shooting.ui.unit.UnitBase;
	import shooting.ui.unit.UnitKind;
	import shooting.ui.unit.waypack.WayPackSet0;
	
	import utils.Library;

	public class UnitTest_UnitMove extends Sprite
	{
		[Embed(source='../assets/res.swf', mimeType='application/octet-stream')]
		private var CRes:Class;
		private var m_lib:Library;
		private var myLayer:BitmapLayer;
		private var unitContainer:UnitContainer;
		private var msContainer:MissileContainer;
		private var msLayer:BitmapLayer;
		
		public function UnitTest_UnitMove()
		{
			super();
			m_lib = new Library(new CRes(),onInit);
			
		}
		private function onInit():void
		{
			msContainer = new MissileContainer();
			msContainer.setArea(-100, -100, 600, 700);
			
			msLayer = new BitmapLayer(m_lib);
			msLayer.initLayer(500,600);
			msLayer.setContainer(msContainer);
			
			
			unitContainer = new UnitContainer();
			unitContainer.addUnit(new UnitBase(UnitKind.UNIT_NOMAL, new Point(200,0),WayPackSet0.STAY_CENTER,100, 0, msContainer));
			unitContainer.addUnit(new UnitBase(UnitKind.UNIT_NOMAL, new Point(400,0),WayPackSet0.STAY_CENTER, 100, 0, msContainer));
			
			myLayer = new BitmapLayer(m_lib);
			myLayer.initLayer(500, 600);
			myLayer.setContainer(unitContainer);
			
			this.addChild(msLayer);
			this.addChild(myLayer);
			
			addEvents();
		}
		private function addEvents():void
		{
			this.addEventListener( Event.ENTER_FRAME, unitRendering);
			this.addEventListener( Event.ENTER_FRAME, msRendering);
		}
		private function unitRendering( e:Event):void
		{
			unitContainer.render();
			myLayer.render();			
		}
		private function msRendering( e:Event ):void
		{
			msContainer.render();
			msLayer.render();
		}
	}
}